package com.example;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 演示测试sk应用程序
 *
 * @author lolka
 * @date 2021/08/26
 */
@SpringBootApplication
@MapperScan("com.example.mapper")
@EnableScheduling
public class DemoTestSkApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoTestSkApplication.class, args);
        System.out.println("启动完成======》");
    }

    @Bean
    public DefaultRedisScript<Long> stockScript() {
        DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();
        //放在和application.yml 同层目录下
        redisScript.setLocation(new ClassPathResource("stock.lua"));
        redisScript.setResultType(Long.class);
        System.out.println(redisScript.getScriptAsString());
        return redisScript;
    }

}
